﻿using App_Clinique.ClassLibrary.DbContext;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App_Clinique.ClassLibrary.Entities
{
    public partial class Actualite
    {
        /****************************************************************************************************
         * Methods - Inser, Update, Delete
         ***************************************************************************************************/
        public static void Create(Actualite actualite)
        {
            using (App_cliniqueContext db = new App_cliniqueContext())
            {
                db.Actualite.Add(actualite);
                db.SaveChanges();
            }
        }

        public static void Update(Actualite actualite)
        {
            using (App_cliniqueContext db = new App_cliniqueContext())
            {
                db.Entry(actualite).State = EntityState.Modified;
                db.SaveChanges();
            }
        }

        public static void Delete(Actualite actualite)
        {
            using (App_cliniqueContext db = new App_cliniqueContext())
            {
                db.Entry(actualite).State = EntityState.Deleted;
                db.SaveChanges();
            }
        }

        /****************************************************************************************************
         * Methods - Select
         ***************************************************************************************************/
        public static Actualite Get(Int64 actualiteID)
        {
            Actualite Obj = null;

            using (App_cliniqueContext db = new App_cliniqueContext())
            {
                Obj = (from c in db.Actualite
                       where c.ActualiteID == actualiteID
                       select c).SingleOrDefault();
            }

            return Obj;
        }

        public static List<Actualite> GetList()
        {
            List<Actualite> objs = null;

            using (App_cliniqueContext db = new App_cliniqueContext())
            {
                objs = (from c in db.Actualite
                        select c).ToList();
            }

            return objs;
        }
    }
}
